import JsBridge from './JsBridge';

class Session {
    constructor() {
        this.userInfo = null;
    }

    login(userInfo) {
        this.userInfo = userInfo;
        //Cookies.set("yxtUser", userInfo);

        localStorage.setItem("yxtUser", JSON.stringify(userInfo));
    }

    logout() {
        this.userInfo = null;
//      Cookies.remove('yxtUser');
		localStorage.removeItem('yxtUser');
    }

    getUser(needRefresh) {
        if (! this.userInfo || needRefresh) {
            this.userInfo = JSON.parse(localStorage.getItem('yxtUser'));
        }

        return this.userInfo;
    }
}

export default new Session();
